#region using
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Data;
using BLToolkit.Mapping;
using BLToolkit.Data;
using BLToolkit.DataAccess;
using BLToolkit.EditableObjects;
#endregion

namespace Brainsoft.Core.BusinessLogic
{
    /// <summary>
    /// Este objeto representa las propiedades y metodos de ApplicationGroup.
    /// Nomenclatura a usar para los SP = ApplicationGroup_SelectByKey , ApplicationGroup_Update, etc.
    /// En caso contrario usar el nombre de los SP como atributos de la clase, ej:
    ///[ActionSprocName("SelectAll", "NombreProcedimiento")], [ActionSprocName("Insert", "NombreProcedimiento")], etc.
    /// </summary>	

    public class ApplicationGroups
    {

        #region Constructors
        public ApplicationGroups()
        {
        }
        #endregion

        #region Private Properties
        private int _applicationGroupID;
        private string _applicationGroupName = String.Empty;
        private int _sortOrder;
        private bool _visible;
        #endregion

        #region Public Properties
        public int ApplicationGroupID
        {
            get { return _applicationGroupID; }
            set { _applicationGroupID = value; }
        }

        public string ApplicationGroupName
        {
            get { return _applicationGroupName; }
            set { _applicationGroupName = value; }
        }

        public int SortOrder
        {
            get { return _sortOrder; }
            set { _sortOrder = value; }
        }

        public bool Visible
        {
            get { return _visible; }
            set { _visible = value; }
        }
        #endregion

        #region Relational Properties

        #endregion

        #region Generic Methods

        #region Insert, Update, Delete

        public void Insert(ApplicationGroups obj)
        {
            Query.Insert(obj);
        }
        public bool BatchInsert(List<ApplicationGroups> list)
        {
            using (DbManager db = new DbManager())
            {
                db.BeginTransaction();
                try
                {
                    foreach (ApplicationGroups obj in list)
                    {
                        obj.Insert(obj);
                    }
                }
                catch
                {
                    db.RollbackTransaction();
                    return false;
                }
                db.CommitTransaction();
                return true;
            }
        }

        public void Update(ApplicationGroups obj)
        {
            Query.Update(obj);
        }

        public void Delete(ApplicationGroups obj)
        {
            Query.Delete(obj);
        }

        public void Delete(int id)
        {
            Query.DeleteByKey(id);
        }

        #endregion

        #region Select

        public List<ApplicationGroups> SelectAll()
        {
            return Query.SelectAll();
        }

        public ApplicationGroups SelectByKey(object[] parameters)
        {
            return Query.SelectByKey(parameters);
        }

        #endregion

        #endregion

        #region Custom Methods

        #endregion

        #region Protected Members
        protected DbManager db;

        private SprocQuery<ApplicationGroups> _query;
        protected virtual SprocQuery<ApplicationGroups> Query
        {
            get
            {
                if (null == _query)
                    db = new DbManager("Connection String");                
                    _query = new SprocQuery<ApplicationGroups>(db);
                return _query;
            }
        }

        #endregion
    }
}
